<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- START DEFAULT DATATABLE -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">问卷填写情况</h3>
        <%--<button class="btn btn-default">再加一个</button>--%>
    </div>
    <div class="panel-heading">
        <div class="pull-right">
            <input type="hidden" id="questionnaireId" value="${questionnaireId}">
            <button type="button" class="btn btn-info" id="group-export" onclick="exportDatas()">导出答卷数据</button>
        </div>
    </div>
    <div class="panel-body">
        <table class="table">
            <thead>
            <tr>
                <th>公司/部门</th>
                <th>姓名</th>
                <th>手机号</th>
                <th>填写时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${userAnswers}" var="root">
                <tr class="item-comment comment-quote info" id="${root.id}">
                    <td>${root.deptName}</td>
                    <td>${root.name}</td>
                    <td>${root.phone}</td>
                    <td class="addTime" data-val="${root.addTime}"></td>
                    <td>
                        <button class="btn btn-info btn-rounded btn-sm" title="查看填写情况" onclick="goView(${root.id})"><span
                                class="fa  fa-align-justify"></span></button>
                        <button class="btn btn-danger btn-rounded btn-sm" title="删除"
                                onClick="delete_row(${root.id});"><span class="fa fa-times"></span></button>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<!-- END DEFAULT DATATABLE -->

<!-- MESSAGE BOX-->
<div class="message-box message-box-warning animated fadeIn" id="mb-remove-row">
    <div class="mb-container">
        <div class="mb-middle">
            <div class="mb-title"><span class="fa fa-times"></span> <strong>删除该答卷</strong> ?</div>
            <div class="mb-content">
                <p>你确定要删除这个答卷吗？</p>
            </div>
            <div class="mb-footer">
                <div class="pull-right">
                    <button class="btn btn-info btn-lg mb-control-yes">确定</button>
                    <button class="btn btn-default btn-lg mb-control-close">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- END MESSAGE BOX-->

<!-- START SCRIPTS -->
<div id="ifm"></div>
<script>
    $(function () {
        $.each($('td.addTime'), function (index, item) {
            var s = $(item).attr('data-val');
            $(item).html(format(new Date(s), "yyyy-MM-dd HH:mm:ss"));
        });
    });
    function delete_row(row) {
        var param = {};
        param.id = row;
        var box = $("#mb-remove-row");
        box.addClass("open");
        box.find(".mb-control-yes").on("click", function () {
            json("/admin/option/delUserAnswer.jspa", param, function (data) {
                if (data.code == 0) {
                    box.removeClass("open");
                    $("#" + row).hide("slow", function () {
                        $(this).remove();
                    });
                } else {
                    alert(data.description);
                }
            });
        });
    }
    function goView(o) {
        window.location.href = '/admin/option/viewUserAnswer.jspa?id=' + o;
    }
    var isDo = 0;
    function exportDatas() {
        if (isDo == 1)
            return;
        var questionnaireId = $("#questionnaireId").val();
        isDo = 1;
        $("#group-export").html("正在导出 ... ");
        $('#ifm').html('<iframe id="downFrame" name="downFrame" width="0" height="0" src="' +
                '/admin/option/repairOrderExport.jspa?questionnaireId=' + questionnaireId+'" onload="downFrameOver()"></iframe>');
//            $("#downFrame").attr("src", "/admin/statistics/downOrder.jspx?type=fin&arrive=" + a + "&t=" + (new Date()));
        isDo = 0;
    }
    function downFrameOver() {
        isDo = 0;
        $("#group-export").html("导出答卷表");
    }

</script>
